/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package models.Skill.Instant.general;

import cstAndEnum.*;
import java.util.List;
import models.Game;
import models.Player;
import models.Skill.Instant.SkillInstant;
import models.Skill.Skill;

/**
 *
 * @author Muzi
 */
public class SkillInstantSha extends SkillInstant{
    /**
     * 杀伤力，初始为-1
     */
    protected int execution;

    /**
     * 技能施展
     * @param targets
     * @param source
     * @param game
     * @return
     */
    @Override
    public boolean cast(List<Player> targets, Player source,Game game) {
        String r="SkillInstantSha--cast:";
        for(int i=0;i<targets.size();i++){
            Player aTarget=targets.get(i);
            int distance=game.getListPlayer().distanceBetween(source, aTarget);
            if(source.getDeckEqp().getWeapon()==null){//没有武器
                if(distance>1){
                    r="Failed: "+r+" "+source.getName()+"can't attack "+aTarget.getName();
                    CST.println(r);
                }
            }
            else{//有武器
                if(source.getDeckEqp().getWeapon().getRange()>distance){
                    r+=source.getName()+"attack "+aTarget.getName();
//                    CST.println("To "+aTarget.getName()+" : Do you want dodge");//等待被攻击者出闪
//                    boolean
//                    Skill.modifBlood(targets, execution);
                }
            }
        }        
        return true;
    }

    /**
     *constructor
     */
    public SkillInstantSha() {
        super("Sha");
        this.execution = -1;
    }

    // getters, setters
    public int getExecution() {
        return execution;
    }

    public void setExecution(int execution) {
        this.execution = execution;
    }
}
